package cn.com.cetccst.datacenter.policy.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;

import java.util.List;

import cn.com.cetccst.datacenter.collection.dao.BaseDao;
import cn.com.cetccst.datacenter.policy.entity.RestrictionEntity;
import cn.com.cetccst.datacenter.policy.entity.RestrictionStatusEntity;

@Dao
public interface RestrictionStatusDao extends BaseDao<RestrictionStatusEntity> {

    @Query("SELECT * FROM " + RestrictionStatusEntity.TABLE_NAME)
    LiveData<List<RestrictionStatusEntity>> loadRestrictions();

    @Query("SELECT * FROM " + RestrictionStatusEntity.TABLE_NAME)
    List<RestrictionStatusEntity> getRestrictions();

    @Query("DELETE FROM " + RestrictionEntity.TABLE_NAME)
    void clearAll();

    @Transaction
    default void cleanAndInsert(List<RestrictionStatusEntity> entities) {
        clearAll();
        insertAll(entities);
    }
}
